package org.boulderfoodrescue.webapp.client.pickups;

import org.boulderfoodrescue.webapp.shared.Pickup;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

public class PickupView extends Composite{

	private static ScheduleDataGridUiBinder uiBinder = GWT
			.create(ScheduleDataGridUiBinder.class);

	interface ScheduleDataGridUiBinder extends
	UiBinder<Widget, PickupView> {
	}

	public PickupView(PickupTable dataGrid, PickupInterface pickupInterface) {
		this.dataGrid = dataGrid;
		initWidget(uiBinder.createAndBindUi(this));

		this.pickupInterface = pickupInterface;
	}

	@UiField(provided=true)
	PickupTable dataGrid;
	@UiField
	Button newPickupButton;

	private PickupInterface pickupInterface;

	@UiHandler("newPickupButton")
	public void onNewPickupButtonClick(ClickEvent event)
	{
		pickupInterface.onNewPickupButtonClick();
	}

	public void addPickup(Pickup pickup){
		dataGrid.addPickup(pickup);
	}

	public void refresh() {
		dataGrid.refreshTable();
	}

}
